<html>
<head><meta charset="utf-8"><title>More missing syntax highlights · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/More.20missing.20syntax.20highlights.html">More missing syntax highlights</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="197376171"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/More%20missing%20syntax%20highlights/near/197376171" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/More.20missing.20syntax.20highlights.html#197376171">(May 13 2020 at 07:21)</a>:</h4>
<p><a href="user_uploads/4715/UhpmNYu74vwj6CN9AKuciXxv/image.png">image.png</a></p>
<div class="message_inline_image"><a href="user_uploads/4715/UhpmNYu74vwj6CN9AKuciXxv/image.png" title="image.png"><img src="user_uploads/4715/UhpmNYu74vwj6CN9AKuciXxv/image.png"></a></div><p>Looks like we don't highlight macro imports at all.</p>



<a name="197438763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/More%20missing%20syntax%20highlights/near/197438763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> woody77 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/More.20missing.20syntax.20highlights.html#197438763">(May 13 2020 at 16:29)</a>:</h4>
<p>I think that this is a theme issue.  You're using "Default Dark+" on VSCode, correct?  If so, adding these to your settings.json will give some more highlighting:</p>
<div class="codehilite"><pre><span></span><code> &quot;editor.semanticTokenColorCustomizations&quot;: {
        &quot;enabled&quot;: true,

        &quot;rules&quot;: {
            // All-themes colors
            &quot;unresolvedReference&quot;: {
               &quot;foreground&quot;: &quot;#c93f3f&quot;,
               &quot;fontStyle&quot;: &quot;bold&quot;
            } ,
            &quot;*.mutable&quot;: {
                &quot;fontStyle&quot;: &quot;underline&quot;
            },
        },

        &quot;[Default Dark+]&quot;: {
            &quot;enabled&quot;: true,
            &quot;rules&quot;:{
                &quot;macro&quot;: &quot;#4EADE5&quot;,
                &quot;member&quot;: &quot;#9876AA&quot;,
                &quot;namespace&quot;: &quot;#A9B7C6&quot;,
            },
        },
</code></pre></div>


<p>The full supported list is:<br>
<a href="https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide#semantic-token-classification">https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide#semantic-token-classification</a><br>
and then rust-analyzer adds:<br>
<a href="https://github.com/rust-analyzer/rust-analyzer/blob/eb892d707c379eff514df9c2a6b2203f38874b14/editors/code/package.json#L537-L587">https://github.com/rust-analyzer/rust-analyzer/blob/eb892d707c379eff514df9c2a6b2203f38874b14/editors/code/package.json#L537-L587</a></p>



<a name="197458497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/More%20missing%20syntax%20highlights/near/197458497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/More.20missing.20syntax.20highlights.html#197458497">(May 13 2020 at 18:47)</a>:</h4>
<p>Thank you for the config example.</p>
<p>Indeed, I use the default theme, yet the actual thing I try to understand is whether there's a way to avoid extra highlighting configuration at all.</p>
<p>What I want to achieve, is the highlighting that "just works"™ for any correct Rust code, which was the case for the old highlighting RA had used before and which is the case for intellij-rust.<br>
I think this way we will avoid a lot of confusion, especially for the newbies and recent VS Code switchers that do not know about those settings. Some of them will come and ask the similar questions I do now.</p>
<p>Is it so that the requried semantic definitions are missing in the Default Dark+? <br>
If it's a matter of a few lines to add, should we rather upstream it there?</p>



<a name="197458989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/More%20missing%20syntax%20highlights/near/197458989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/More.20missing.20syntax.20highlights.html#197458989">(May 13 2020 at 18:50)</a>:</h4>
<p>Speaking of the <code>hashmap</code> macro in particular, what I find very fishy is that we fail to highlight it in the import yet we're fine with highlighting it in the code:</p>
<p><a href="/user_uploads/4715/zZGBCo5deJ_nAh4lIJug0utM/Screenshot-2020-05-13-at-21.46.48.png">Screenshot-2020-05-13-at-21.46.48.png</a> </p>
<div class="message_inline_image"><a href="/user_uploads/4715/zZGBCo5deJ_nAh4lIJug0utM/Screenshot-2020-05-13-at-21.46.48.png" title="Screenshot-2020-05-13-at-21.46.48.png"><img src="/user_uploads/4715/zZGBCo5deJ_nAh4lIJug0utM/Screenshot-2020-05-13-at-21.46.48.png"></a></div><p>It looks like the same token type is assigned to both the import and the usage, yet the former is not highlighted and the latter is.<br>
Can that be an actual bug?</p>



<a name="197478767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/More%20missing%20syntax%20highlights/near/197478767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> woody77 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/More.20missing.20syntax.20highlights.html#197478767">(May 13 2020 at 21:15)</a>:</h4>
<p>The problem you're running into is the default themes (not RA).  IntelliJ, for instance, has much more fine-grained theming by default).</p>
<p>In the examples you linked, the formatting is coming from the different TextMate rules.  There isn't any matching rule for the semantic type "macro".  When semantic highlighting is enabled, and the theme uses it, the inspect data reflects that:<br>
<a href="/user_uploads/4715/yhwMejg5OCITo99WhRlj6j5-/Screen-Shot-2020-05-13-at-2.13.08-PM.png">Screen-Shot-2020-05-13-at-2.13.08-PM.png</a> </p>
<div class="message_inline_image"><a href="/user_uploads/4715/yhwMejg5OCITo99WhRlj6j5-/Screen-Shot-2020-05-13-at-2.13.08-PM.png" title="Screen-Shot-2020-05-13-at-2.13.08-PM.png"><img src="/user_uploads/4715/yhwMejg5OCITo99WhRlj6j5-/Screen-Shot-2020-05-13-at-2.13.08-PM.png"></a></div><p>The textmate formatting is crossed out, and the formats are taken from the semantic rules (note that it matches the color in the semantic color customizations that I gave in the example above).</p>



<a name="197519791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/More%20missing%20syntax%20highlights/near/197519791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/More.20missing.20syntax.20highlights.html#197519791">(May 14 2020 at 07:47)</a>:</h4>
<p>Ah, so upstream changes then.<br>
Thank you for explaining!</p>



<a name="197546353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/More%20missing%20syntax%20highlights/near/197546353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/More.20missing.20syntax.20highlights.html#197546353">(May 14 2020 at 12:42)</a>:</h4>
<p>Keep in mind that themes need to explicitly opt in to semantic highlighting as well.</p>



<a name="197621206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/More%20missing%20syntax%20highlights/near/197621206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> George Fraser <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/More.20missing.20syntax.20highlights.html#197621206">(May 14 2020 at 21:33)</a>:</h4>
<p>Kiril we've done a bunch of work recently to try to make syntax work better in it's default configuration. Coloring of macros as "function-like things" should work out of the box. Can you submit a bug with a complete example and tag me please? I'm <code>@georgewfraser</code> on github.</p>



<a name="197632140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/More%20missing%20syntax%20highlights/near/197632140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> woody77 <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/More.20missing.20syntax.20highlights.html#197632140">(May 14 2020 at 23:38)</a>:</h4>
<p>George Fraser it looks like the fallback textmate scope for the import is just "source.rust", so it looks like the semantic fallback scope isn't being setup to match that of where it's used ("entity.name.function.macro.rust").</p>



<a name="197663412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/More%20missing%20syntax%20highlights/near/197663412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/More.20missing.20syntax.20highlights.html#197663412">(May 15 2020 at 08:52)</a>:</h4>
<p>Thanks George, I've created one: <a href="https://github.com/rust-analyzer/rust-analyzer/issues/4462">https://github.com/rust-analyzer/rust-analyzer/issues/4462</a> and tagged you.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>